package shellstation;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;

public class editReceiptView implements ActionListener {

    private JPanel panel2;

    private JTable receiptTable;

    private DefaultTableModel receiptChoice;

    private JLabel monthLabel;
    private JLabel dayLabel;
    private JLabel yearLabel;
    private JLabel receiptNumberL;

    private JScrollPane scrollpane;

    private JButton Update;
    private JButton find;

    private Icon findImage;

    private JTextField year;
    private JTextField receiptNo;

    private JComboBox month;
    private JComboBox day;

    private Integer[] monthNum = new Integer[13];
    private Integer[] dayNum = new Integer[32];

    private String[] columnName = {"Receipt Number", "Date"};
    private Object[][] rowData= {
                                    {"11039752", "11 - 14 - 2011"},
                                    {"11008571", "11 - 14 - 2011"},
                                    {"11025093", "11 - 14 - 2011"},
                                    {"11014172", "11 - 14 - 2011"}
                                };

    public void editReceiptView(){

        for(int i=0; i<31; i++){
            dayNum[i]= i+1;

            if(i<12)
            monthNum[i] = i+1;
        }

        receiptNumberL= new JLabel("Receipt No:");
        receiptNumberL.setBounds(15, 10, 125, 50);
        receiptNumberL.setFont(new Font("Arial", Font.BOLD, 15));

        monthLabel= new JLabel("Month");
        monthLabel.setBounds(15, 40, 125, 50);
        monthLabel.setFont(new Font("Arial", Font.BOLD, 15));

        dayLabel= new JLabel("Day");
        dayLabel.setBounds(135, 40, 125, 50);
        dayLabel.setFont(new Font("Arial", Font.BOLD, 15));

        yearLabel= new JLabel("Year");
        yearLabel.setBounds(240, 40, 125, 50);
        yearLabel.setFont(new Font("Arial", Font.BOLD, 15));

        receiptNo= new JTextField("", 5);
        receiptNo.setBounds(110, 26, 80, 20);

        month= new JComboBox(monthNum);
        month.setBounds(75, 56, 50, 20);

        day= new JComboBox(dayNum);
        day.setBounds(175, 56, 50, 20);

        year= new JTextField("",4);
        year.setBounds(285, 56, 50, 20);

        receiptChoice = new DefaultTableModel(rowData, columnName){
            public boolean isCellEditable(int rowData, int columnName){
                return false;
            };
        };
        receiptChoice.setColumnIdentifiers(columnName);
        receiptChoice.setRowCount(15);

        receiptTable= new JTable(receiptChoice);
        receiptTable.setFillsViewportHeight(true);
        receiptTable.setPreferredScrollableViewportSize(new Dimension(100,200));

        scrollpane= new JScrollPane(receiptTable);
        scrollpane.setBounds(23, 100, 400, 220);

        Update= new JButton("Edit Receipt");
        Update.setBounds(150, 340, 140, 30);
        Update.addActionListener(this);

        findImage= new ImageIcon(getClass().getResource("image/search.gif"));

        find = new JButton();
        find.setIcon(findImage);
        find.setBackground(null);
        find.setBounds(215, 20, 25, 25);
    }

    public void actionPerformed (ActionEvent e){

        if(e.getSource() == Update){
            panel2.removeAll();

            editReceiptForm ef= new editReceiptForm();
            ef.setPanel(panel2);
            ef.editReceiptFormPanel();

          

            panel2.repaint();
            panel2.revalidate();
        }
    }

    public JTextField getreceiptNo(){
        return receiptNo;
    }

    public JComboBox getmonth(){
        return month;
    }

    public JComboBox getday(){
        return day;
    }

    public JTextField getyear(){
        return year;
    }

    public JTable getreceiptTable(){
        return receiptTable;
    }

    public JScrollPane getscrollPane(){
        return scrollpane;
    }

    public JLabel getreceiptNumberL(){
        return receiptNumberL;
    }

    public JLabel getmonthLabel(){
        return monthLabel;
    }

    public JLabel getdayLabel(){
        return dayLabel;
    }
    
    public JLabel getyearLabel(){
        return yearLabel;
    }

    public JButton getUpdate(){
        return Update;
    }

    public JButton getfind(){
        return find;
    }

    public void setPanel(JPanel panel){
        panel2 = panel;
    }
}
